package com.lzs.collection.traverse;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

public class Collectionfor {
    @SuppressWarnings("all")
    public static void main(String[] args) {
        List<Dog> list = new ArrayList<>();
        list.add(new Dog("小黑",3));
        list.add(new Dog("大黄",5));
        list.add(new Dog("大壮",8));

        //增强for循环遍历集合
        for (Dog dog : list) {
            System.out.println(dog);
        }
    }
    //Dog作为非静态内部类，在静态方法main中无法直接实例化
    @Data
    @AllArgsConstructor
    static class Dog {
        private String name;
        private int age;
    }

}
